import request from "../utils/request"

export interface HomeDataModel {
  data: {
    // 导航分类图标的数据
    kingKongModule: {
      norColor: string,
      background: string,
      // 导航栏数据
      kingKongList: KingKongModel[],
      selectedColor: string
    },
    // 新人专享礼列表数据
    indexActivityModule: IndexActivityModuleModel[],
    // 轮播图列表数据
    focusList: FocusModel[],
    // 趣出游 - 严选直播数据
    sceneLightShoppingGuideModule: SceneLightShoppingGuideModel[],
    // 周年庆活动数据
    bigPromotionModule: {
      floorList: BigPromotionModel[]
    },
    // 类目热销榜数据
    categoryHotSellModule: {
      title: string,
      categoryList: CategoryModel[]
    }
  }
}
// 类目热销榜数据中商品列表数据的类型
export interface CategoryModel {
  picUrl: string,
  categoryName: string,
  extra: {
    operationResource: {
      categoryName: string,
      categoryId: string,
    }
  },
  targetUrl: string,
  showPicUrl: string,
}
// 周年庆列表数据类型
export interface BigPromotionModel {
  layout: number,
  cells: CellModel[],
  taskId: number,
}
// 周年庆详情数据类型
interface CellModel {
  schemeUrl: string,
  picUrl: string,
  targetUrl: string,
  itemList: {
    picUrl: string,
    id: number
  }[],
  id: string
}
// 趣出游 - 严选直播数据类型
export interface SceneLightShoppingGuideModel {
  styleBanner?: {
    picUrl: string,
    originSchemeUrl: string,
    title: string,
    targetUrl: string,
    desc: string,
  }
  styleItem?: {
    itemFrom: string
    picUrlList: string[]
    title: string
    targetUrl: string
    desc: string
    originSchemeUrl: string
  }
}
// 轮播图列表数据的类型
export interface FocusModel {
  picUrl: string,
  name?: string,
  id?: string,
  originSchemeUrl?: string,
  targetUrl?: string,
}
// 导航分类图标的数据列表类型
export interface KingKongModel {
  picUrl: string,
  schemeUrl: string,
  text: string,
  textColor: string,
}
// 新人专享礼列表数据类型
export interface IndexActivityModuleModel {
  picUrl: string,
  subTitle: string,
  originPrice: string,
  tag: string,
  title: string,
  targetUrl: string,
  showPicUrl: string,
  activityPrice: string,
}

// 指定频道数据的返回值类型
export interface ThisCategoryModel {
  data: {
    categoryItemList: CategoryItemModel[],
    currentCategory: {
      id: string,
      name: string,
      bannerList: { picUrl: string }[],
      targetUrl: string
    }
  }
}
// 指定频道数据的返回值中数据列表的类型
export interface CategoryItemModel {
  category: {
    id: string,
    superCategoryId: string,
    name: string,
    frontName: string,
  },
  itemList: ItemModel[]
}
// 返回值中数据列表中每一项商品的类型
export interface ItemModel {
  id: string,
  listPicUrl: string,
  name: string,
  retailPrice: string,
  sortOriginPrice: string,
  colorNum: number,
  productPlace: string,
  finalPriceInfoVO: {
    banner: {
      title: string,
      content: string
    },
    priceInfo: {
      counterPrice: string,
      finalPrice: {
        prefix: string | null,
        price: string
      }
    }
  },
  preLogo: PreLogoModel[],
  topLogo: {
    logoUrl: string,
  },
}
export interface PreLogoModel {
  logoUrl: string,
  width: number,
  height: number
}
export const homeApi = {
  // 获取首页数据
  getHomeData() {
    return request.get<any, HomeDataModel>('/dapi/xhr/index.json?__timestamp=1630131808529')
  },

  // 获取指定频道数据
  getThisCategoryData(categoryId: string) {
    return request.get<any, ThisCategoryModel>(`/dapi/item/list.json?__timestamp=1630136511866&categoryId=${categoryId}`)
  }
}
